<template>
  <div class="row8">
    <div class="box" id="信用信息采集总数">
      <!-- 这个盒子是用来放下拉选择框的 -->
      <div class="col_1 echarts" id="row8_col_1"></div>
    </div>
    <div class="box">
      <div class="col_2 echarts" id="row8_col_2"></div>
    </div>
    <div class="box" id="省级公共信用等级企业总数">
      <div class="col_3 echarts" id="row8_col_3"></div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  name: "row8",
  // 数据
  data() {
    return {};
  },
  // 页面加载就执行
  mounted() {
    this.getCol8_1(
      document.querySelector("#row8_col_1"),
      "8.1基础信用信息-柱状图(条)"
    );
    this.getCol8_2(
      document.querySelector("#row8_col_2"),
      "8.2行政许可-市级报送分析柱状图(条)"
    );
    this.getCol8_3(
      document.querySelector("#row8_col_3"),
      "8.3公共信用等级-年度归集柱状图(家次)"
    );
  },
  // 监听器 监听数据变化
  watch: {},
  // 方法
  methods: {
    // 8.1
    async getCol8_1(domName, title) {
      const { data: res } = await this.$http.get(
        "http://172.16.1.170:8080/cxdsj/dsjAction.jcxySelect.do"
      );
      // console.log('8.1', res);
      let str = res.substring(5);
      let jcxy = eval("(" + str + ")");
      const myChart = echarts.init(domName);
      var option = {
        title: {
          text: title,
          textStyle: {
            color: "#8fc4ff",
            fontsize: "20px",
            fontweight: "bolder",
            fontStyle: "normal",
          },
          top: "3%",
          left: "center",
        },
        toolbox: {
          feature: {
            // saveAsImage: { show: true }, // 导出图片
            myFull: {
              // 全屏
              show: true,
              title: "全屏",
              icon: "path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891",
              onclick: () => {
                // 全屏查看
                if (domName.requestFullScreen) {
                  // HTML W3C 提议
                  domName.requestFullScreen();
                } else if (domName.msRequestFullscreen) {
                  // IE11
                  domName.msRequestFullScreen();
                } else if (domName.webkitRequestFullScreen) {
                  // Webkit
                  domName.webkitRequestFullScreen();
                } else if (domName.mozRequestFullScreen) {
                  // Firefox
                  domName.mozRequestFullScreen();
                }
                // 退出全屏
                if (domName.requestFullScreen) {
                  document.exitFullscreen();
                } else if (domName.msRequestFullScreen) {
                  document.msExitFullscreen();
                } else if (domName.webkitRequestFullScreen) {
                  document.webkitCancelFullScreen();
                } else if (domName.mozRequestFullScreen) {
                  document.mozCancelFullScreen();
                }
              },
            },
          },
        },
        grid: {
          top: "30%",
          left: "-8%",
          bottom: "0%",
          right: "8%",
          containLabel: true,
        },
        tooltip: {
          show: true,
        },
        animation: false,
        xAxis: [
          {
            type: "category",
            // data: ['行政许可', '行政执法', '行政强制', '行政确认', '行政奖励', '行政监督检查'],
            data: jcxy.map((item) => {
              return item.name;
            }),
            axisTick: {
              alignWithLabel: true,
            },
            nameTextStyle: {
              color: "#82b0ec",
            },
            axisLine: {
              show: false,
              lineStyle: {
                color: "#82b0ec",
              },
            },
            axisLabel: {
              interval: "0",
              rotate: "-40",
              textStyle: {
                color: "#fff",
                fontSize: 13,
              },
              margin: 30,
              interval: "0",
            },
          },
        ],
        yAxis: [
          {
            show: false,
            type: "value",
            axisLabel: {
              textStyle: {
                color: "#fff",
              },
            },
            splitLine: {
              lineStyle: {
                color: "#0c2c5a",
              },
            },
            axisLine: {
              show: false,
            },
          },
        ],
        series: [
          {
            name: "",
            type: "pictorialBar",
            symbolSize: [40, 10],
            symbolOffset: [0, -6], // 上部椭圆
            symbolPosition: "end",
            z: 12,
            // "barWidth": "0",
            label: {
              normal: {
                show: true,
                position: "top",
                // "formatter": "{c}%"
                fontSize: 15,
                fontWeight: "bold",
                color: "#34DCFF",
              },
            },
            color: "#2DB1EF",
            // data: [50, 60, 80, 90, 60, 90],
            data: jcxy.map((item) => {
              return item.value;
            }),
          },
          {
            name: "",
            type: "pictorialBar",
            symbolSize: [40, 10],
            symbolOffset: [0, 7], // 下部椭圆
            // "barWidth": "20",
            z: 12,
            color: "#2DB1EF",
            // data: [50, 60, 80, 90, 60, 90],
            data: jcxy.map((item) => {
              return item.value;
            }),
          },
          {
            name: "",
            type: "pictorialBar",
            symbolSize: function (d) {
              return d > 0 ? [50, 15] : [0, 0];
            },
            symbolOffset: [0, 12], // 下部内环
            z: 10,
            itemStyle: {
              normal: {
                color: "transparent",
                borderColor: "#2EA9E5",
                borderType: "solid",
                borderWidth: 1,
              },
            },
            // data: [50, 60, 80, 90, 60, 90],
            data: jcxy.map((item) => {
              return item.value;
            }),
          },
          {
            name: "",
            type: "pictorialBar",
            symbolSize: [70, 20],
            symbolOffset: [0, 18], // 下部外环
            z: 10,
            itemStyle: {
              normal: {
                color: "transparent",
                borderColor: "#19465D",
                borderType: "solid",
                borderWidth: 2,
              },
            },
            // data: [50, 60, 80, 90, 60, 90],
            data: jcxy.map((item) => {
              return item.value;
            }),
          },
          {
            type: "bar",
            //silent: true,
            barWidth: "40",
            barGap: "10%", // Make series be overlap
            barCateGoryGap: "10%",
            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 0.7, [
                  {
                    offset: 0,
                    color: "#38B2E6",
                  },
                  {
                    offset: 1,
                    color: "#0B3147",
                  },
                ]),
                opacity: 0.8,
              },
            },
            // data: [50, 60, 80, 90, 60, 90],
            data: jcxy.map((item) => {
              return item.value;
            }),
          },
        ],
      };
      // 3.把配置项给实例对象
      myChart.setOption(option);
      window.addEventListener("resize", function () {
        myChart.resize();
      });
    },
    // 8.2
    async getCol8_2(domName, title) {
      const tit = ["", "报送总数", "省级迟报", "国家级迟报"];
      function handleOne(arr, titleArr = [], newArr = []) {
        if (titleArr.length !== 0) newArr.push(titleArr);
        arr.forEach((item) => {
          newArr.push(Object.values(item));
          // newArr.push(Object.key(item))
        });
        // console.dir(Object);
        return newArr;
      }
      const { data: res } = await this.$http.get(
        "http://172.16.1.170:8080/cxdsj/dsjAction.xzxkbsSelect.do"
      );
      let str = res.substring(5);
      let xzxkCity = eval("(" + str + ")");
      // console.log('8.2', xzxkCity);
      let newArr = handleOne(xzxkCity, tit);
      const myChart = echarts.init(domName);
      var option = {
        title: {
          text: title,
          textStyle: {
            color: "#ffffff",
            fontsize: "20px",
            fontweight: "bolder",
            fontStyle: "normal",
          },
          top: "3%",
          left: "center",
        },
        toolbox: {
          feature: {
            // saveAsImage: { show: true }, // 导出图片
            myFull: {
              // 全屏
              show: true,
              title: "全屏",
              icon: "path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891",
              onclick: () => {
                // 全屏查看
                if (domName.requestFullScreen) {
                  // HTML W3C 提议
                  domName.requestFullScreen();
                } else if (domName.msRequestFullscreen) {
                  // IE11
                  domName.msRequestFullScreen();
                } else if (domName.webkitRequestFullScreen) {
                  // Webkit
                  domName.webkitRequestFullScreen();
                } else if (domName.mozRequestFullScreen) {
                  // Firefox
                  domName.mozRequestFullScreen();
                }
                // 退出全屏
                if (domName.requestFullScreen) {
                  document.exitFullscreen();
                } else if (domName.msRequestFullScreen) {
                  document.msExitFullscreen();
                } else if (domName.webkitRequestFullScreen) {
                  document.webkitCancelFullScreen();
                } else if (domName.mozRequestFullScreen) {
                  document.mozCancelFullScreen();
                }
              },
            },
          },
        },
        legend: {
          top: "13%",
          textStyle: {
            color: "#ccc",
          },
        },
        tooltip: {},
        grid: {
          top: "25%",
          left: "3%",
          right: "4%",
          bottom: "10%",
          containLabel: true,
        },
        color: ["#6c6be2", "#8e53b9", "#18b794"],
        dataset: {
          // 数据变化
          // source: [
          //   ['', '报送总数', '省级迟报', '市级迟报'],
          //   ['石家庄', 43.3, 85.8, 93.7],
          //   ['衡水', 83.1, 73.4, 55.1],
          //   ['保定', 86.4, 65.2, 82.5],
          //   ['沧州', 72.4, 53.9, 39.1],
          //   ['秦皇岛', 50, 60, 90],
          //   ['定州', 83.1, 73.4, 55.1],
          //   ['雄安', 43.3, 85.8, 93.7],
          //   ['唐山', 83.1, 73.4, 55.1],
          //   ['廊坊', 86.4, 65.2, 82.5],
          //   ['承德', 72.4, 53.9, 39.1],
          //   ['辛集', 50, 60, 90],
          //   ['新乐', 83.1, 73.4, 55.1],
          //   ['邢台', 43.3, 85.8, 93.7],
          // ]
          source: newArr,
        },
        xAxis: {
          type: "category",
          axisLabel: {
            color: "rgba(255, 255, 255, .6)",
          },
        },
        yAxis: {
          axisLabel: {
            color: "rgba(255, 255, 255, .6)",
          },
          axisLine: {
            show: false,
          },
          axisTick: {
            show: false,
          },
        },
        // 添加滚动
        // 添加滚动
        dataZoom: [
          {
            show: true,
            height: 12,
            xAxisIndex: [0],
            bottom: "5%",
            start: 0,
            end: 30,
            handleIcon:
              "path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z",
            handleSize: "110%",
            handleStyle: {
              color: "#d3dee5",
            },
            textStyle: {
              color: "#fff",
            },
            borderColor: "#90979c",
          },
          {
            type: "inside",
            show: true,
            height: 15,
            start: 1,
            end: 35,
          },
        ],
        // Declare several bar series, each will be mapped
        // to a column of dataset.source by default.
        series: [{ type: "bar" }, { type: "bar" }, { type: "bar" }],
      };
      // 3.把配置项给实例对象
      myChart.setOption(option);
      //  4.
      window.addEventListener("resize", function () {
        myChart.resize();
      });
    },
    // 8.3
    async getCol8_3(domName, title) {
      const { data: res } = await this.$http.get(
        "http://172.16.1.170:8080/cxdsj/dsjAction.ggxySelect.do"
      );
      // console.log('8.3', res);
      let str = res.substring(5);
      let ggDj = eval("(" + str + ")");
      const myChart = echarts.init(domName);
      var option = {
        title: {
          text: title,
          textStyle: {
            color: "#8fc4ff",
            fontsize: "20px",
            fontweight: "bolder",
            fontStyle: "normal",
          },
          top: "3%",
          left: "center",
        },
        toolbox: {
          feature: {
            // saveAsImage: { show: true }, // 导出图片
            myFull: {
              // 全屏
              show: true,
              title: "全屏",
              icon: "path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891",
              onclick: () => {
                // 全屏查看
                if (domName.requestFullScreen) {
                  // HTML W3C 提议
                  domName.requestFullScreen();
                } else if (domName.msRequestFullscreen) {
                  // IE11
                  domName.msRequestFullScreen();
                } else if (domName.webkitRequestFullScreen) {
                  // Webkit
                  domName.webkitRequestFullScreen();
                } else if (domName.mozRequestFullScreen) {
                  // Firefox
                  domName.mozRequestFullScreen();
                }
                // 退出全屏
                if (domName.requestFullScreen) {
                  document.exitFullscreen();
                } else if (domName.msRequestFullScreen) {
                  document.msExitFullscreen();
                } else if (domName.webkitRequestFullScreen) {
                  document.webkitCancelFullScreen();
                } else if (domName.mozRequestFullScreen) {
                  document.mozCancelFullScreen();
                }
              },
            },
          },
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
        },
        legend: {
          top: "15%",
          data: ["A级", "B级", "C级", "D级"],
          textStyle: {
            color: "#ccc",
          },
          itemStyle: {},
        },
        grid: {
          top: "30%",
          left: "3%",
          right: "4%",
          bottom: "0%",
          containLabel: true,
        },
        yAxis: {
          type: "value",

          splitLine: {
            show: true,
            lineStyle: {
              color: "#D2E6F9",
              type: "dashed",
            },
          },
          axisLine: {
            lineStyle: {
              color: "#D2E6F9",
            },
          },
          axisTick: {
            show: false,
          },
          axisLabel: {
            color: "#fff",
          },
        },
        xAxis: {
          type: "category",
          // data: ['2021', '2022','2023'],
          data: ggDj.map((item) => {
            return item.year;
          }),
          axisLine: {
            lineStyle: {
              color: "#D2E6F9",
            },
          },
          axisTick: {
            show: false,
          },
          axisLabel: {
            color: "#fff",
            textStyle: {
              fontSize: 15,
            },
          },
        },
        color: ["#A35AE0", "#0CEBEA", "#1fa9e3", "#c2c65e"],
        series: [
          {
            name: "A级",
            type: "bar",
            barWidth: 20,
            barGap: "40%",
            // data: [18, 23, 29],
            data: ggDj.map((item) => {
              return item.numA;
            }),
            itemStyle: {
              barBorderRadius: [4, 24, 0, 0],
            },
          },
          {
            name: "B级",
            type: "bar",
            barWidth: 20,
            barGap: "40%",
            // data: [23, 28, 36],
            data: ggDj.map((item) => {
              return item.numB;
            }),
            itemStyle: {
              barBorderRadius: [4, 24, 0, 0],
            },
          },
          {
            name: "C级",
            type: "bar",
            barWidth: 20,
            barGap: "40%",
            // data: [26, 32, 20],
            data: ggDj.map((item) => {
              return item.numC;
            }),
            itemStyle: {
              barBorderRadius: [4, 24, 0, 0],
            },
          },
          {
            name: "D级",
            type: "bar",
            barWidth: 20,
            barGap: "40%",
            // data: [16, 12, 21],
            data: ggDj.map((item) => {
              return item.numD;
            }),
            itemStyle: {
              barBorderRadius: [4, 24, 0, 0],
            },
          },
        ],
      };
      // 3.把配置项给实例对象
      myChart.setOption(option);
      window.addEventListener("resize", function () {
        myChart.resize();
      });
    },
  },
};
</script>

<style lang="less" scoped>
.row8 {
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  height: 350px;
  .box {
    // flex: 3.5;
    position: relative;
    height: 100%;
    width: 30%;
    border: 1px solid #1480f0;
    &:nth-child(2) {
      width: 39%;
      border: 1px solid #1480f0;
    }

    & /deep/ .el-input__inner {
      background-color: transparent !important;
      max-width: 120px !important;
      max-height: 30px !important;
      color: #fff;
    }

    .echarts {
      position: relative;
      padding: 10px !important;
      height: 100%;
      width: 100%;

      // & /deep/ canvas {
      //   //background-color: #333;
      // }
    }

    &:nth-child(2n - 1) {
      border: 1px solid rgba(25, 186, 139, 0.17);
      background: #050d4b url(@/static/images/line_1.png);
      padding: 0 0.1875rem 0.1875rem;
      margin-bottom: 0.1875rem;
      flex-direction: column;
      justify-content: space-between;
    }
    &:first-child {
      &::before {
        position: absolute;
        top: 0;
        left: 0;
        width: 10px;
        height: 10px;
        border-left: 2px solid #02a6b5;
        border-top: 2px solid #02a6b5;
        content: "";
      }
      &::after {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 10px;
        height: 10px;
        border-left: 2px solid #02a6b5;
        border-bottom: 2px solid #02a6b5;
        content: "";
      }
    }
    &:last-child {
      &::before {
        position: absolute;
        top: 0;
        right: 0;
        width: 10px;
        height: 10px;
        border-right: 2px solid #02a6b5;
        border-top: 2px solid #02a6b5;
        content: "";
      }
      &::after {
        position: absolute;
        bottom: 0;
        right: 0;
        width: 10px;
        height: 10px;
        border-right: 2px solid #02a6b5;
        border-bottom: 2px solid #02a6b5;
        content: "";
      }
    }
  }
}
</style>